package io.netty.example.http.websocketx.common.util;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;

import java.util.List;

/**
 * @author fuguangli
 * @description 前沿类
 * @Create date:    2017/4/28
 */
public class NettyMessageDecode extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List<Object> list) throws Exception {
        byte[] bytes = new byte[byteBuf.readableBytes()];
        byteBuf.readBytes(bytes);

        Object obj = ByteObjConvert.byteToObject(bytes);
        list.add(obj);
    }
}
